package org.ktm.dao;

import java.io.Serializable;
import java.util.Collection;
import org.ktm.core.KTMContext;
import org.ktm.domain.KTMEntity;
import org.ktm.exception.DeleteException;

public abstract class AbstractHibernateStorageDao extends DaoImplHibernate
	implements Dao {

	private static final long	serialVersionUID	= 1L;

	public KTMEntity get( Serializable id ) {
		return get( getFeaturedClass(), id );
	}

	public int delete( Serializable id ) throws DeleteException {
		return delete( getFeaturedClass(), id );
	}

	public Collection<?> findAll() {
		return findAll( getFeaturedClass() );
	}

	public Collection<?> find( int pageNumber ) {
		if ( KTMContext.paging > 0 ) {
			setMaxResults( KTMContext.paging );
			setFirstResult( getMaxResults() * ( pageNumber - 1 ) );
		}
		return find( getFeaturedClass() );
	}

	public long getCount() {
		return getCount( getFeaturedClass() );
	}
}
